package org.xjtu.weteam.common.utils;

import org.xjtu.weteam.model.domain.User;

/**
 * @author Kevin
 */
public class SecurityUtils {

    public static User getCurrentUser() {
        return SessionUtils.getCurrentUser();
    }

    public static Integer getCurrentUserId() {
        User currentUser = getCurrentUser();
        return currentUser != null ? currentUser.getUserId() : null;
    }

    public static User getCurrentUserInfo() {
        User currentUser = getCurrentUser();
        if (currentUser != null) {
            return new User()
                    .setUserId(currentUser.getUserId())
                    .setOpenId(currentUser.getOpenId())
                    .setNickname(currentUser.getNickname())
                    .setGender(currentUser.getGender())
                    .setStatus(currentUser.getStatus())
                    .setRole(currentUser.getRole())
                    .setPhone(currentUser.getPhone())
                    .setCreateTime(currentUser.getCreateTime())
                    .setUpdateTime(currentUser.getUpdateTime());
        }
        return null;
    }

}
